function debounce(fn: Function, delay: number) {
    let timer: number | null = null;

    return function (...args: any[]) {
        if (timer) {
            clearTimeout(timer); // 清除上次的定时器
        }

        timer = setTimeout(() => {
            fn(...args); // 延迟执行函数
        }, delay);
    };
}

export {debounce}